package com.xxbb.chapter_2.dome_sort;

public class Programma {

    public static void main(String[] args) {
        //冒泡排序
        int m[] = {5, 10, 9, 4, 2};
        for (int i = 1; i < m.length; i++) {
            for (int j = 0; j < m.length - 1; j++) {
                if (m[j] > m[j + 1]) {
                    int temp = m[j];
                    m[j] = m[j + 1];
                    m[j + 1] = temp;
                }
            }
            System.out.println("第" + i + "轮排序的结果为：");
            for (int k = 0; k < m.length; k++) {
                System.out.print(m[k] + "");
            }
            System.out.println();
        }
        System.out.print("最终的排序结果为：");
        for (int i = 0; i < m.length; i++) {
            System.out.print(m[i] + " ");
        }

    }
}

